package Lotr.game;

import java.awt.Image;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;

public class Resources {

    private List[] trollSprites;
    private final int trollRightS = 14, trollLeftS = 14, trollUpS = 13, trollDownS = 13; 
    private final String trollDir = "/Lotr/sprites/Enemies/troll";
    private List[] dragonSprites;
    private final int dragonRightS = 0, dragonLeftS = 0, dragonUpS = 0, dragonDownS = 0;
    private final String dragonDir = "/Lotr/sprites/Enemies/dragon";
    private List[] orkSprites;
    private final int orkRightS = 8, orkLeftS = 8, orkUpS = 12, orkDownS = 12;
    private final String orkDir = "/Lotr/sprites/Enemies/ork";
    private List[] urukSprites;
    private final int urukRightS = 12, urukLeftS = 12, urukUpS = 12, urukDownS = 12;
    private final String urukDir = "/Lotr/sprites/Enemies/uruk";
    private List[] wargSprites;
    private final int wargRightS = 0, wargLeftS = 0, wargUpS = 0, wargDownS = 0;
    private final String wargDir = "/Lotr/sprites/Enemies/warg";
    

    public Resources() throws IOException {
        loadResources();
    }

    private void loadResources() throws IOException {
        loadTrollSprites();
        loadOrkSprites();
        loadDragonSprites();
        loadUrukSprites();
        loadWargSprites();
    }

    private void loadTrollSprites() throws IOException{
        trollSprites = new List[4];
        trollSprites[Path.UP] = new ArrayList<Image>();
        for(int i = 1; i <= trollUpS; i++){
            trollSprites[Path.UP].add(ImageIO.read(this.getClass().getResource(trollDir+"/up/"+i+".png")));
        }
        trollSprites[Path.DOWN] = new ArrayList<Image>();
        for(int i = 1; i < trollDownS; i++){
            trollSprites[Path.DOWN].add(ImageIO.read(this.getClass().getResource(trollDir+"/down/"+i+".png")));
        }
        trollSprites[Path.LEFT] = new ArrayList<Image>();
        for(int i = 1; i < trollLeftS; i++){
            trollSprites[Path.LEFT].add(ImageIO.read(this.getClass().getResource(trollDir+"/left/"+i+".png")));
        }
        trollSprites[Path.RIGHT] = new ArrayList<Image>();
        for(int i = 1; i < trollRightS; i++){
            trollSprites[Path.RIGHT].add(ImageIO.read(this.getClass().getResource(trollDir+"/right/"+i+".png")));
        }
    }
    
    private void loadOrkSprites() throws IOException{
        orkSprites = new List[4];
        orkSprites[Path.UP] = new ArrayList<Image>();
        for(int i = 1; i <= orkUpS; i++){
            orkSprites[Path.UP].add(ImageIO.read(this.getClass().getResource(orkDir+"/up/"+i+".png")));
        }
        orkSprites[Path.DOWN] = new ArrayList<Image>();
        for(int i = 1; i < orkDownS; i++){
            orkSprites[Path.DOWN].add(ImageIO.read(this.getClass().getResource(orkDir+"/down/"+i+".png")));
        }
        orkSprites[Path.LEFT] = new ArrayList<Image>();
        for(int i = 1; i < orkLeftS; i++){
            orkSprites[Path.LEFT].add(ImageIO.read(this.getClass().getResource(orkDir+"/left/"+i+".png")));
        }
        orkSprites[Path.RIGHT] = new ArrayList<Image>();
        for(int i = 1; i < orkRightS; i++){
            orkSprites[Path.RIGHT].add(ImageIO.read(this.getClass().getResource(orkDir+"/right/"+i+".png")));
        }
    }
    
    private void loadDragonSprites() throws IOException{
        dragonSprites = new List[4];
        dragonSprites[Path.UP] = new ArrayList<Image>();
        for(int i = 1; i <= dragonUpS; i++){
            dragonSprites[Path.UP].add(ImageIO.read(this.getClass().getResource(dragonDir+"/up/"+i+".png")));
        }
        dragonSprites[Path.DOWN] = new ArrayList<Image>();
        for(int i = 1; i < dragonDownS; i++){
            dragonSprites[Path.DOWN].add(ImageIO.read(this.getClass().getResource(dragonDir+"/down/"+i+".png")));
        }
        dragonSprites[Path.LEFT] = new ArrayList<Image>();
        for(int i = 1; i < dragonLeftS; i++){
            dragonSprites[Path.LEFT].add(ImageIO.read(this.getClass().getResource(dragonDir+"/left/"+i+".png")));
        }
        dragonSprites[Path.RIGHT] = new ArrayList<Image>();
        for(int i = 1; i < dragonRightS; i++){
            dragonSprites[Path.RIGHT].add(ImageIO.read(this.getClass().getResource(dragonDir+"/right/"+i+".png")));
        }
    }
    
    private void loadUrukSprites() throws IOException{
        urukSprites = new List[4];
        urukSprites[Path.UP] = new ArrayList<Image>();
        for(int i = 1; i <= urukUpS; i++){
            urukSprites[Path.UP].add(ImageIO.read(this.getClass().getResource(urukDir+"/up/"+i+".png")));
        }
        urukSprites[Path.DOWN] = new ArrayList<Image>();
        for(int i = 1; i < urukDownS; i++){
            urukSprites[Path.DOWN].add(ImageIO.read(this.getClass().getResource(urukDir+"/down/"+i+".png")));
        }
        urukSprites[Path.LEFT] = new ArrayList<Image>();
        for(int i = 1; i < urukLeftS; i++){
            urukSprites[Path.LEFT].add(ImageIO.read(this.getClass().getResource(urukDir+"/left/"+i+".png")));
        }
        urukSprites[Path.RIGHT] = new ArrayList<Image>();
        for(int i = 1; i < urukRightS; i++){
            urukSprites[Path.RIGHT].add(ImageIO.read(this.getClass().getResource(urukDir+"/right/"+i+".png")));
        }
    }
    
    private void loadWargSprites() throws IOException{
        wargSprites = new List[4];
        wargSprites[Path.UP] = new ArrayList<Image>();
        for(int i = 1; i <= wargUpS; i++){
            wargSprites[Path.UP].add(ImageIO.read(this.getClass().getResource(wargDir+"/up/"+i+".png")));
        }
        wargSprites[Path.DOWN] = new ArrayList<Image>();
        for(int i = 1; i < wargDownS; i++){
            wargSprites[Path.DOWN].add(ImageIO.read(this.getClass().getResource(wargDir+"/down/"+i+".png")));
        }
        wargSprites[Path.LEFT] = new ArrayList<Image>();
        for(int i = 1; i < wargLeftS; i++){
            wargSprites[Path.LEFT].add(ImageIO.read(this.getClass().getResource(wargDir+"/left/"+i+".png")));
        }
        wargSprites[Path.RIGHT] = new ArrayList<Image>();
        for(int i = 1; i < wargRightS; i++){
            wargSprites[Path.RIGHT].add(ImageIO.read(this.getClass().getResource(wargDir+"/right/"+i+".png")));
        }
    }
    
    public List[] getTrollSprites() {
        return trollSprites;
    }
    
    public List[] getOrkSprites(){
        return orkSprites;
    }
    
    public List[] getDragonSprites(){
        return dragonSprites;
    }
    
    public List[] getUrukSprites(){
        return urukSprites;
    }
    
    public List[] getWargSprites(){
        return wargSprites;
    }
    
}
